package com.googlecode.kipler.syntax.concept;


public class AtConcept extends Concept {
	private String name;

	private Concept concept;

	public AtConcept() {

	}

	public AtConcept(String name, Concept concept) {
		super();
		setName(name);
		setConcept(concept);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Concept getConcept() {
		return concept;
	}

	public void setConcept(Concept concept) {
		this.concept = concept;
	}

	@Override
	public boolean isNegated() {
		return false;
	}

	@Override
	public Concept toggleNegated() {
		getConcept().toggleNegated();
		return this;
	}

	@Override
	public void accept(ConceptVisitor v) {
		v.visitAtConcept(this);
	}

	@Override
	public Concept copy() {
		AtConcept result = new AtConcept();
		result.setName(getName());
		result.setConcept(getConcept().copy());
		result.setLeftBiased(isLeftBiased());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj != null && (obj.getClass().equals(this.getClass()))) {
			AtConcept other = (AtConcept) obj;
			return (this.isLeftBiased() == other.isLeftBiased()
					&& this.getName().equals(other.getName()) && this
					.getConcept().equals(other.getConcept()));
		}
		return false;
	}

	@Override
	public int hashCode() {
		return 17 * 37 + new Boolean(isLeftBiased()).hashCode()
				+ getName().hashCode() + getConcept().hashCode();
	}
	
	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		buffer.append("@");
		buffer.append("(");
		buffer.append(getName());
		buffer.append(", ");
		buffer.append(getConcept());
		buffer.append(")");
		return buffer.toString();
	}

}
